package io.github.wanggit.antrpc.demos.circuit_breaker.circuit_breaker_consumer.web;

import io.github.wanggit.antrpc.commons.annotations.RpcAutowired;
import io.github.wanggit.antrpc.demos.circuit_breaker.GlobalBreakerService;
import io.github.wanggit.antrpc.demos.circuit_breaker.HasDefaultHandlerBreakerService;
import io.github.wanggit.antrpc.demos.circuit_breaker.UserDefinedBreakerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestController {

    @RpcAutowired
    private GlobalBreakerService globalBreakerService;

    @RpcAutowired
    private UserDefinedBreakerService userDefinedBreakerService;

    @RpcAutowired
    private HasDefaultHandlerBreakerService hasDefaultHandlerBreakerService;

    @GetMapping("g")
    public String doGlobal(@RequestParam("content") String content){
        return globalBreakerService.doLowerCase(content);
    }

    @GetMapping("ud")
    public String doUserDefined(@RequestParam("content") String content){
        return userDefinedBreakerService.doUpperCase(content);
    }

    @GetMapping("hd")
    public String doHasDefault(@RequestParam("content") String content){
        return hasDefaultHandlerBreakerService.reverse(content);
    }


}
